SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.[DnnProduct_CDS_TemplateDeleteStamp]
	@DistributorID varchar(50),
	@TemplateID int,
	@DefaultStampConfigID int,
	@DRMType varchar(20)
AS
BEGIN
	IF (coalesce(@DRMType, 'Stamp') = 'Stamp')
		DELETE FROM [DnnProduct_CDS_StampSets]
		WHERE TemplateID = @TemplateID AND DefaultStampConfigID = @DefaultStampConfigID
		AND TemplateID IN (SELECT ID FROM [DnnProduct_CDS_Templates] WHERE DistributorID = @DistributorID)
	ELSE
		DELETE FROM [DnnProduct_CDS_StampSets]
		WHERE TemplateID = @TemplateID AND DefaultDRMStampConfigID = @DefaultStampConfigID
		AND TemplateID IN (SELECT ID FROM [DnnProduct_CDS_Templates] WHERE DistributorID = @DistributorID)
END
GO
